'''
	Marks the start of the program.
	It collects all the urls containing the links to all the revisions.
	Stores the list in the file - 'historyLinks.txt'
'''



import urllib2
from lxml import html
from lxml import etree
import connect as con
import config as cg
    
def main( url ):
	
	f = open(cg.history_links, 'a')
	
	tree = con.connectToPage(url)
	while True:
		f.write(url + "\n")
		
		url = "http://en.wikipedia.org";
		for element in tree.iterlinks():
			try:
				if element[0].text == 'newer 500':
					url = "http://en.wikipedia.org" + element[2];
			except:
				prevPage = "";
		if url == "http://en.wikipedia.org":
			break;
		tree = con.connectToPage(url);

		

main(cg.url);
	
